<?php
/**
 * TODO: Copyright
 */

/**
 * NextOfKin Service class for communication between controllers and persistent storage
 */
class Core_Service_NextOfKin extends RedCross_Service_ServiceAbstract
{
    /**
     * Constructor
     * @param Core_Gateway_NextOfKin $gateway
     */
    public function __construct(Core_Gateway_NextOfKin $gateway)
    {
        parent::__construct($gateway, 'Core_Model_NextOfKin');
    }

    /**
     * Deletes a next of kin object from the database
     * @param Core_Model_NextOfKin The NextOfKin model to be deleted
     * @return bool Whether or not the deletion was successful
     */
    public function delete($nextOfKinModel)
    {
        // TODO: Make sure only the user that owns this nextOfKin kan delete it
        // or that the user has access to deleteAny acl

        //$userId = $authService->getIdentity()->id;
        //$userService = $this->_helper->getService('Core_Service_User');
        //$user = $this->_userService->fetchByIdForProfile($userId);

        // TODO: ?!
        //$this->checkAcl('delete');

        if(!$nextOfKinModel instanceof Core_Model_NextOfKin) {
            throw new RedCross_Service_Exception('Incorrect parameter given');
        }

        return $nextOfKinModel->delete();
    }
}
